﻿@model RTW.OA.Areas.Personal.Models.AddressViewModel
@{
    Layout = "~/Views/Shared/_LayoutBase.cshtml";
}
@section styles{
    <link href="@Url.Content("~/Content/css/common/bootstrap-table/bootstrap-table.min.css")" rel="stylesheet" />
    <link href="@Url.Content("~/Content/css/common/animate/animate.min.css")" rel="stylesheet" />
}
<div id="dMain">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="ibox" style="margin-bottom: 0px;">
            <div class="ibox-title">
                <h4>@ViewBag.Title </h4>
            </div>
            <div class="ibox-content">
                <div class="group">
                    <div class="left">
                        <dl>
                            <dt class="left1"><span><i class="iconfont icon-user" style="color:forestgreen;"></i></span>我的分组</dt>
                            <dd style="margin-left:0px;">
                                <ul class="leftul" style="height:auto;overflow-y:auto;overflow-x: hidden;position:relative;top:0px;left:0px;">
                                    <li class="fz" onclick="changeGroup('','');" style="text-align: left; background-color: rgb(247, 247, 247);"><span class="left-span" style="top:0px;top:10px;"><i class="iconfont icon-menu" width="22" height="22"></i></span><span style="margin-left:61px;">默认组</span></li>
                                    @if (Model.AddressGroupLists != null && Model.AddressGroupLists.Any())
                                    {
                                        foreach (var item in Model.AddressGroupLists)
                                        {
                                            <li class="fz" style="position: relative; background-color: rgb(247, 247, 247);" onclick="changeGroup('@item.GROUP_ID' ,'@item.USER_ID');" title="@item.GROUP_NAME">
                                                <span style="margin-right:54px;">@item.GROUP_NAME</span><span class="dl" style="position:absolute;right:20px;top:5px;" onclick="delete_group('@item.GROUP_ID');">
                                                    <i class="iconfont  icon-shanchu1" style="color:crimson;"></i>
                                                </span>
                                            </li>
                                        }
                                    }
                                </ul>
                            </dd>
                        </dl>
                        <button type="button" class="btn btn-success" style="width:120px;height:35px;margin-left:40px;margin-top: 10px;" onclick="create_group()">新建分组</button>
                    </div>
                    <div id="div_Content" class="right" style="width: 787px;height: auto;overflow: hidden;">
                        @*<iframe style="width:100%;height:400px;" id="group_edit" name="group_edit" frameborder="0" src="@Url.Action("ShowGroup","Address",new {  area="Personal" })?GROUP_ID=0"></iframe>*@
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

@section scripts{
    <script src="@Url.Content("~/Content/JS/common/WdatePicker/WdatePicker.js")"></script>
    <script type="text/javascript" charset="utf-8" src="@Url.Content("~/Content/JS/common/jquery/Validform_v5.3.2_min.js")"></script>
    <script type="text/javascript" charset="utf-8" src="@Url.Content("~/Content/JS/common/artdialog/dialog-plus-min.js")"></script>
    <script type="text/javascript" charset="utf-8" src="@Url.Content("~/Content/JS/common/webuploader/webuploader.min.js")"></script>
    <script type="text/javascript" charset="utf-8" src="@Url.Content("~/Content/editor/ueditor.config.js")"></script>
    <script type="text/javascript" charset="utf-8" src="@Url.Content("~/Content/editor/ueditor.all.min.js")"></script>
    <script type="text/javascript" charset="utf-8" src="@Url.Content("~/Content/editor/lang/zh-cn/zh-cn.js")"></script>
    @*<script type="text/javascript" charset="utf-8" src="../js/uploader.js"></script>*@

    <script src="@Url.Content("~/Content/JS/common/from.js")"></script>
    <script>
        $(document).ready(function () {
            changeGroup("","");
        });

        //* 分组改變，已选成员、备选成员的值對應改變
        function changeGroup(groupId, userId) {
            $("#div_Content").empty();
            $.ajax({
                type: "POST",
                async: false,
                url: '@Url.Action("ShowGroup", "Address", new { area = "Personal" })',
                data: { "groupId": groupId, "userId": userId },
                success: function (data) {
                    $("#div_Content").html(data);
                }
            });            
        }

        function create_group() {
            $("#div_Content").empty();
            $.ajax({
                type: "GET",
                traditional: true,
                url: '@Url.Action("AddressGroupEdit","Address",new { area="Personal"})',
                async: true,
                data: { "id": "" },
                success: function (data) {
                    $("#div_Content").html(data);
                },
                error: function () {

                }
            });
        }

        function delete_group(id) {
            layer.confirm('是否删除此分组信息？', {
                btn: ['确定', '取消'] //按钮
            }, function () {
                var url = '@Url.Action("AddressGroupDelete", "Address", new { area = "Personal" })\/' + id;
                $.ajax({
                    type: "POST",
                    traditional: true,
                    url: url,
                    async: true,
                    success: function (data) {
                        $("#dMain").load(data);
                        layer.msg('删除分组信息表成功！', {
                            icon: 1,
                            time: 2000//2s后自动关闭
                        });
                    },
                    error: function () {

                    }
                });
            }, function () {

            });
        }
    </script>

}